package com.theta.gateway.infra.common.exception;

import lombok.Setter;

import com.theta.gateway.infra.common.exception.enums.ErrorEnum;

import lombok.Getter;

@SuppressWarnings("serial")
@Getter
@Setter
public class BusinessException extends RuntimeException {

    private int code;
    private String msg;
    private ErrorEnum errorEnum;
    private Object data;

    public BusinessException(ErrorEnum errorEnum) {
        super(errorEnum.getMessage());
        this.code = errorEnum.getCode();
        this.msg = errorEnum.getMessage();
        this.errorEnum=errorEnum;
    }

    public BusinessException(int code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }
    
    public BusinessException(int code, String msg,Object data) {
        super(msg);
        this.code = code;
        this.msg = msg;
        this.data=data;
    }

    public BusinessException(ErrorEnum errorEnum, String... args) {
        super(String.format(errorEnum.getMessage(), args));
        this.code = errorEnum.getCode();
    }

}
